# -*- coding: utf-8 -*-

import pandas as pd
import numpy as np
from functools import reduce


df1 = pd.DataFrame(np.array([
    ['a', 1, 2],
    ['b', 3, 4],
    ['c', 5, 6]]),
    columns=['name', 'num11', 'num12'])
df2 = pd.DataFrame(np.array([
    ['a', 7, 8],
    ['b', 9, 10],
    ['c', 11, 12]]),
    columns=['name', 'num21', 'num22'])
df3 = pd.DataFrame(np.array([
    ['a', 13, 14],
    ['b', 15, 16],
    ['c', 17, 18]]),
    columns=['name', 'num31', 'num32'])
print(df1)
print(df2)
print(df3)
dfs = [df1, df2, df3]
# df_result = reduce(lambda left, right: pd.merge(left, right, on='name'), dfs)
df_result = reduce(lambda left, right: pd.merge(left, right,how="top", on='name'), dfs)
# df_result = reduce(lambda top, bottom: pd.merge(top, bottom, on='name'), dfs)
print(df_result)
